# Contributor: Andy Li <andy@onthewings.net>
# Maintainer: Andy Li <andy@onthewings.net>
pkgname=ocaml-qcheck
_pkgname=qcheck
pkgver=0.12
pkgrel=1
pkgdesc="QuickCheck inspired property-based testing for OCaml"
url="https://github.com/c-cube/qcheck"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune ocaml ocaml-findlib ocaml-ounit-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	dune build @install -p qcheck,qcheck-core,qcheck-ounit -j1 --no-buffer --verbose
}

check() {
	dune runtest --no-buffer
}

package() {
	mkdir -p "$pkgdir"/usr/lib/ocaml
	dune install \
		--destdir="$pkgdir" \
		qcheck qcheck-core qcheck-ounit

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc

	# Remove annotation files and sources.
	local path; for path in $(find "$pkgdir"/usr/lib/ocaml \
		-name '*.cmt' \
		-o -name '*.ml')
	do
		rm "$path"
	done
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \
		-name '*.cmx' \
		-o -name '*.cmxa' \
		-o -name '*.mli')
	do
		mkdir -p "${path%/*}"
		mv "$path" "$subpkgdir"/${path%/*}/
	done
}

sha512sums="a8b844d66b65fdc8cd1cb2ff1a84801815501559dccac5e4188593f5b294ca318f7de971987ce810b6f7840a292999a98ea8beb1e2c989ee3abd78314fca3ad3  ocaml-qcheck-0.12.tar.gz"
